<template>
	<div class="city-list">
		<section class="">
		    <header class="header-body">
		        <div class="header">
		            <h1 class="title">选择城市</h1>
		        </div>
		        <a class="go-back" href="javascript:;" @click="goback"></a>
		    </header>
		    <article class="article-body">
		        <div class="items-body" data-number="0">
		            <div class="items">
		                <p class="items-title" key-value="当前">当前城市</p>
		                <div class="items-content">
		                    <a href="javascript:void(0);" @click="goback">{{ selected }}</a>
		                </div>
		            </div>
		            <div class="items">
		                <p class="items-title">城市列表</p>
		                <div class="items-content">
		                    <a v-for="(cityList,key) in cityLists" :key="key" @click="selectCity(cityList.title,cityList.id)">{{ cityList.title }}</a>
		                </div>
		            </div>
		        </div>
		    </article>
		</section>
		
	</div>
</template>

<script>
	export default{
		name:'cityList',
		data(){
			return{
				cityLists:[],
				selected:this.$store.state.city.city_title
			}
		},
		created(){
			this.cityGet()
	
		},
		methods:{
			cityGet(){
				this.$get('api/city').then(res=>{
					if(res.code == 0){
						this.cityLists = res.data
					}
				})
			},
			goback(){
				this.$router.go(-1)
			},
			selectCity(n,v){
				this.$store.commit('cityId',v)
			//	if(this.$route.query.redirect=='index'){
				
					this.$router.push(this.$route.query.redirect+'/'+v)
				

				//console.log(this.$router.path)
				
			}
		}
	}
</script>

<style scoped>
 @import '../assets/css/select-city.css';
    .city-list {background-color: #fff;}
</style>
